clear all;
close all;

A=double(imread('lena1.tif'));
freq = hist(A(:), 256);
[x, y] = size(A);
prob = freq/(x*y);

pos = find(prob);
H1 = -sum(prob(pos).*log2(prob(pos)))

err = A(2:x,:)-A(1:x-1,:);
freq = hist(err(:), 512);
prob = freq/(x*y);

pos = find(prob);
H2 = -sum(prob(pos).*log2(prob(pos)))